package com.longjianghuasheng.logistics.business.freight.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.longjianghuasheng.logistics.R
import com.longjianghuasheng.logistics.databinding.ItemTransportBinding
import com.longjianghuasheng.logistics.entity.FreightResponse
import com.longjianghuasheng.logistics.ext.loadUrl
import com.longjianghuasheng.logistics.ext.setAdapterAnimation

class TransportListAdapter :
    BaseQuickAdapter<FreightResponse, BaseDataBindingHolder<ItemTransportBinding>>(R.layout.item_transport) {

    var onListener = { id: Int ->

    }

    override fun convert(
        holder: BaseDataBindingHolder<ItemTransportBinding>,
        item: FreightResponse
    ) {

        holder.dataBinding?.run {
            tvServiceName.text = item.title
            tvDescript.text = item.descript
            ivPic.loadUrl(item.picurl)
            btnApply.setOnClickListener { onListener.invoke(item.id ?: 0) }
        }
        holder.itemView.setOnClickListener {

            onListener.invoke(item.id ?: 0)
        }
    }
}